import turtle
import math

# 设置画布
screen = turtle.Screen()
screen.title("蜘蛛侠")
screen.bgcolor("white")

# 创建绘图对象
spider = turtle.Turtle()
spider.speed(3)  # 控制绘制速度
spider.pensize(2)

# 绘制头部轮廓
def draw_head():
    spider.penup()
    spider.goto(0, -150)
    spider.pendown()
    spider.begin_fill()
    spider.color("red")
    # 绘制一个椭圆作为头部
    for i in range(2):
        spider.circle(100, 90)
        spider.circle(50, 90)
    spider.end_fill()

# 绘制眼睛
def draw_eyes():
    # 左眼睛
    spider.penup()
    spider.goto(-40, 0)
    spider.pendown()
    spider.begin_fill()
    spider.color("white")
    spider.circle(20)
    spider.end_fill()
    
    # 右眼睛
    spider.penup()
    spider.goto(40, 0)
    spider.pendown()
    spider.begin_fill()
    spider.color("white")
    spider.circle(20)
    spider.end_fill()
    
    # 左眼瞳孔
    spider.penup()
    spider.goto(-40, 10)
    spider.pendown()
    spider.begin_fill()
    spider.color("black")
    spider.circle(10)
    spider.end_fill()
    
    # 右眼瞳孔
    spider.penup()
    spider.goto(40, 10)
    spider.pendown()
    spider.begin_fill()
    spider.color("black")
    spider.circle(10)
    spider.end_fill()

# 绘制蜘蛛标志
def draw_spider_symbol():
    spider.penup()
    spider.goto(0, -60)
    spider.pendown()
    spider.begin_fill()
    spider.color("black")
    
    # 绘制蜘蛛腹部
    spider.circle(15)
    
    spider.end_fill()
    
    # 绘制蜘蛛腿
    legs = [(-30, -60), (-20, -70), (-10, -75),
            (30, -60), (20, -70), (10, -75)]
    
    spider.penup()
    spider.goto(0, -60)
    spider.pendown()
    spider.color("black")
    
    for leg in legs:
        spider.goto(leg)
        spider.goto(0, -60)

# 绘制蜘蛛网图案
def draw_web():
    spider.penup()
    spider.goto(0, 100)
    spider.pendown()
    spider.color("black")
    
    # 绘制放射状线条
    for _ in range(8):
        spider.forward(150)
        spider.backward(150)
        spider.right(45)
    
    # 绘制圆形线条
    spider.penup()
    spider.goto(0, 100)
    spider.pendown()
    
    for radius in range(30, 160, 30):
        spider.circle(radius, 360)

# 组合绘制
draw_head()
draw_eyes()
draw_spider_symbol()

# 隐藏画笔
spider.hideturtle()

# 保持窗口打开
turtle.done()
